<?php

/**
 * 用户帐号 消费记录 控制器
 *  
 */
class AccountAction extends UserAction {

    protected $model, $log;

    public function _initialize() {
        parent::_initialize();
        $this->model = D('UserAccount');
        $this->log = M('UserAccountLog');
    }

    public function index() {
        $this->display();
    }

    public function log() {
        $uid   = session('uid');
        $model = $this->log;
        $map   = array(
            'user_id' => $uid
        );
        //取得满足条件的记录数
        $count       = $model
                ->where($map)
                ->count();
        if ($count > 0) {
            import("ORG.Util.Page");

            $limit = 8;
            $order = 'create_time DESC';
            //创建分页对象
            $p     = new Page($count, $limit);
            //分页查询数据

            $voList = $model
                    ->where($map)
                    ->order($order)
                    ->limit($p->firstRow . ',' . $p->listRows)
                    ->select();
            //分页模版
            $TP     = '共有{recordcount}条信息&nbsp;{pageindex}/{pagecount}&nbsp;{first}{prev}&nbsp;{liststart}{list}{listend}&nbsp;{next}{last}';
            $p->SetPager('default', $TP, array("listlong"      => "6", "first"         => "首页", "last"          => "尾页", "prev"          => "上一页", "next"          => "下一页", "list"          => "*", "disabledclass" => ""));

            //分页显示
            $page = $p->show();
            //模板赋值显示
            $data = array(
                'list'      => $voList,
                'page'      => $page,
                'nowPage'   => $_REQUEST['page'],
                'totalPage' => round($count / $limit),
            );
        }
        
        //推荐信息
        $roundDZ = _roundDazhe();
        $this->assign('rounddz', $roundDZ);
        $this->assign('data', $data);
        $this->display();
    }

}

?>
